<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>局部组件</title>
    <script src="../js/vue.js"></script>
</head>
<body>
    <div id="app1">
        <my-component>123456789</my-component>   
        <hr>
        <my-component>123456789</my-component>   
    </div>
    <hr>
    <div id="app2">
        <ul>
            <li> <mycomponent>123456789</mycomponent>  </li>
            <li> <mycomponent>123456789</mycomponent>  </li>
            <li> <mycomponent>123456789</mycomponent>  </li>
        </ul>
        
    </div>
    <template id="zwttc">
        <table border="1" width="600" height="100">
            <tr>
                <th>id</th>
                <th>name</th>
                <th>price</th>
            </tr>
            <tr>
                <td></td>
                <td></td>
                <td></td>
            </tr>
            <tr>
                <td></td>
                <td></td>
                <td></td>
            </tr>
            <tr>
                <td></td>
                <td></td>
                <td></td>
            </tr>
            <tr>
                <td></td>
                <td></td>
                <td></td>
            </tr>
        </table>
       
    </template>

    <template id="jjcbl">
        <div>
            <ul>
                <li><a href="#">1</a></li>
                <li><a href="#">2</a></li>
                <li><a href="#">3</a></li>
                <li><a href="#">4</a></li>
                <li><a href="#">{{username}}</a></li>
                <li><a href="#"><button @click='count++'>点我+1 {{count}}</button></a></li>
                <li><a href="#">7</a></li>
                <li><a href="#">8</a></li>
                <li><a href="#">9</a></li>
                <li><a href="#">10</a></li>
            </ul>
            <p>
                <h1>hahahahahahaha</h1>
            </p>
        </div>
      
    </template>

    <script> 
        var app = new Vue({
            el:'#app1'
            ,components:{
                'MyComponent':{
                    template:'#jjcbl'      
                    ,data(){
                        return{
                            username:'周杰吃饱了'
                            ,count:365
                        }
                    }  
                }
            }
        });
        var app2 = new Vue({
            el:'#app2'
            ,components:{
                'mycomponent':{
                    template:`<button @click='count++'>点我+1 {{count}}</button>`
                    ,data(){
                        return {
                            count:2
                        }
                    }
                }
            }
        });

    </script>
</body>
</html>